package org.groupg.project.a;

import java.time.LocalDate;

public class JacksonDemo {
    public static void main(String[] args) throws Exception {
        // 创建员工对象
        Employee emp = new Employee("E-12345", 8500.0);
        emp.setFullName(new FullName("John", "Doe"));
        emp.setEmploymentDate(LocalDate.of(2020, 3, 15));
        emp.setDepartment(Department.IT);
        emp.setSecretToken("TOP_SECRET_123");
        emp.addMetadata("securityClearance", "Level 4");
        emp.addMetadata("remoteWork", true);

        // 添加技能
        emp.addSkill(new TechnicalSkill("Java", 5));
        emp.addSkill(new ManagementSkill("Project Management", "PMP"));

        // JSON 序列化/反序列化
        System.out.println("===== JSON 处理 =====");
        String json = JsonProcessor.toJson(emp);
        System.out.println("序列化结果:\n" + json);

        Employee fromJson = JsonProcessor.fromJson(json);
        System.out.println("\n反序列化后 FullName: " + fromJson.getFullName().getFirstName() +
                " " + fromJson.getFullName().getLastName());

        // XML 序列化/反序列化
        System.out.println("\n===== XML 处理 =====");
        String xml = XmlProcessor.toXml(emp);
        System.out.println("序列化结果:\n" + xml);

        Employee fromXml = XmlProcessor.fromXml(xml);
        System.out.println("\n反序列化后 FullName: " + fromXml.getFullName().getFirstName() +
                " " + fromXml.getFullName().getLastName());
    }
}